package ACWing.acwing每日一题._5995_挖矿;

import java.util.Scanner;

public class Main {
    static int N = 2000000+10;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            int t = scanner.nextInt();
            if(t<0)
                a[-t]++;
            else if(t>0)
                b[t]++;
            else
                ans+=1;
        }
        // 求数轴正负方向的前缀和
        int[] a_sum = new int[m+1];
        int[] b_sum = new int[m+1];
        for (int i = 1; i <= m; i++) {
            a_sum[i] = a_sum[i-1] + a[i];
            b_sum[i] = b_sum[i-1] + b[i];
        }
        long max1 =0,max2=0;
        for (int i = 1; i <= m; i++) {
            // 折返
            if(m - i*2>=0){
                max1 = Math.max(max1, a_sum[i]+b_sum[m-i*2]);   // 先b后a
                max1 = Math.max(max1, b_sum[i]+a_sum[m-i*2]);   // 先a后b
            }
        }
        // 不折返
        max2 = Math.max(a_sum[m],b_sum[m]);
        ans = ans+Math.max(max1,max2);
        System.out.println(ans);

    }
}
